<template>
  <view class="review-tabs">
    <view
      class="review-tabs-item"
      :class="{ active: current === index }"
      v-for="(item, index) in typeList"
      :key="index"
      @click="handleChangeType(item.url)"
    >
      <text>{{ item.name }}</text>
    </view>
  </view>
</template>

<script>
export default {
  components: {},
  props: {
    current: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      typeList: [
        {
          name: "21天抗遗忘打卡",
          type: "1",
          url: "pages/review/review1",
        },
        {
          name: "拉通式复习",
          type: "2",
          url: "pages/review/review2",
        },
      ],
    };
  },
  onLoad() {},
  methods: {
    handleChangeType(url) {
      const pages = getCurrentPages();
      const currentPage = pages[pages.length - 1];
      const currentRoute = currentPage.route;
      if (url === currentRoute) return;
      uni.navigateTo({
        url: url,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
@import "./reviewTabs";
</style>
